package com.baidu.bulls.stock.entity.user;

import com.baidu.bulls.stock.entity.base.BaseEntity;
import com.baidu.bulls.stock.entity.vo.ParentAuthorityMenuVo;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;
import java.io.Serializable;

/**
 * <p>
 * 菜单表
 * </p>
 * @author //蔡志豪
 * @since 2022-02-18
 */
@Data
@Entity
@Api(value = "HATEOAS接口-菜单管理(AuthorityMenu)")
@EqualsAndHashCode(callSuper = false)
@TableName("t_authority_menu")
@Table(name = "t_authority_menu")
@ApiModel(value="AuthorityMenu", description="菜单表")
public class AuthorityMenu extends BaseEntity {

    @ManyToOne(targetEntity =ParentAuthorityMenuVo.class,fetch = FetchType.EAGER) //多对一的关系
    @NotFound(action = NotFoundAction.IGNORE) //级联找不到不抛出异常
    @JoinColumn(name = "parentId",referencedColumnName = "id",insertable = false,updatable = false) //parentId是当前的关联,referenced是vo的关联，修改和插入不要级联操作
    private ParentAuthorityMenuVo parentAuthorityMenuVo;


    @ApiModelProperty(value = "上级menu_id")
    @Column(name = "parentId")
    private Long parentId;

    @ApiModelProperty(value = "机构类型id")
    @Column(name = "institutionTypeId")
    private String institutionTypeId;

    @ApiModelProperty(value = "菜单编码")
    @Column(name = "menuCode")
    private String menuCode;

    @ApiModelProperty(value = "菜单名称")
    @Column(name = "menuName")
    private String menuName;

    @ApiModelProperty(value = "菜单URI")
    @Column(name = "menuUri")
    private String menuUri;

    @ApiModelProperty(value = "菜单等级")
    @Column(name = "menuLevel")
    private Integer menuLevel;

    @ApiModelProperty(value = "是否需要操作授权（0不需要（默认） ，1需要）")
    @Column(name = "operationSecurity")
    private Integer operationSecurity;

    @ApiModelProperty(value = "位置排序")
    @Column(name = "menuSeq")
    private Integer menuSeq;

    @Column(name = "menuIco")
    private String menuIco;

    @ApiModelProperty(value = "菜单状态(0无效,1有效)")
    @Column(name = "status")
    private Integer status;

    @ApiModelProperty(value = "只对2级菜单生效。0闭合，1打开")
    @Column(name = "isOpen")
    private Integer isOpen;

    @ApiModelProperty(value = "是否显示 (0--否  1--是)")
    @Column(name = "isShow")
    private Integer isShow;

    @ApiModelProperty(value = "组件标识（前后分离使用）")
    @Column(name = "componentSrc")
    private String componentSrc;


}
